package com.java1412.floor.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.java1412.floor.domain.ImsModelFloorType;
import com.java1412.floor.service.IImsModelFloorTypeService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 模型文件楼层类型Controller
 *
 * @author ruoyi
 * @date 2023-12-18
 */
@RestController
@RequestMapping("/floor/floor")
public class ImsModelFloorTypeController extends BaseController
{
    @Autowired
    private IImsModelFloorTypeService imsModelFloorTypeService;

    /**
     * 查询模型文件楼层类型列表
     */
    @PreAuthorize("@ss.hasPermi('floor:floor:list')")
    @GetMapping("/list")
    public AjaxResult list(ImsModelFloorType imsModelFloorType)
    {
        List<ImsModelFloorType> list = imsModelFloorTypeService.selectImsModelFloorTypeList(imsModelFloorType);
        return success(list);
    }

    /**
     * 导出模型文件楼层类型列表
     */
    @PreAuthorize("@ss.hasPermi('floor:floor:export')")
    @Log(title = "模型文件楼层类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ImsModelFloorType imsModelFloorType)
    {
        List<ImsModelFloorType> list = imsModelFloorTypeService.selectImsModelFloorTypeList(imsModelFloorType);
        ExcelUtil<ImsModelFloorType> util = new ExcelUtil<ImsModelFloorType>(ImsModelFloorType.class);
        util.exportExcel(response, list, "模型文件楼层类型数据");
    }

    /**
     * 获取模型文件楼层类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('floor:floor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(imsModelFloorTypeService.selectImsModelFloorTypeById(id));
    }

    /**
     * 新增模型文件楼层类型
     */
    @PreAuthorize("@ss.hasPermi('floor:floor:add')")
    @Log(title = "模型文件楼层类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ImsModelFloorType imsModelFloorType)
    {
        return toAjax(imsModelFloorTypeService.insertImsModelFloorType(imsModelFloorType));
    }

    /**
     * 修改模型文件楼层类型
     */
    @PreAuthorize("@ss.hasPermi('floor:floor:edit')")
    @Log(title = "模型文件楼层类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ImsModelFloorType imsModelFloorType)
    {
        return toAjax(imsModelFloorTypeService.updateImsModelFloorType(imsModelFloorType));
    }

    /**
     * 删除模型文件楼层类型
     */
    @PreAuthorize("@ss.hasPermi('floor:floor:remove')")
    @Log(title = "模型文件楼层类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(imsModelFloorTypeService.deleteImsModelFloorTypeByIds(ids));
    }
}
